package cn.airia.as3wplib.service.impl
{
	import cn.airia.as3wplib.cfg.Configuration;
	import cn.airia.as3wplib.rpc.BaseServiceDelegate;
	import cn.airia.as3wplib.rpc.DelegateFactory;
	import cn.airia.as3wplib.service.IBloggerService;
	

	
	public class BloggerServiceImpl implements IBloggerService
	{
		private var xmlrpc_url:String = Configuration.getInstance().xmlrpcUrl;
		private var bloggerXmlrpc:BaseServiceDelegate;
		
		public function BloggerServiceImpl()
		{
			bloggerXmlrpc = DelegateFactory.getDelegate(DelegateFactory.TYPE_XMLRPC,xmlrpc_url);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IBloggerService#getUsersBlogs()
		 */
		public function getUsersBlogs(username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(null,username,password);
			bloggerXmlrpc.invoke("blogger.getUsersBlogs",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IBloggerService#getUserInfo()
		 */
		public function getUserInfo(username:String, password:String, retFun:Function):void
		{
			var params:Array = new Array(null,username,password);
			bloggerXmlrpc.invoke("blogger.getUserInfo",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IBloggerService#getPost()
		 */
		public function getPost(post_id:int,username:String,password:String,retFun:Function):void
		{
			var params:Array = new Array(null,post_id,username,password);
			bloggerXmlrpc.invoke("blogger.getPost",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IBloggerService#getRecentPosts()
		 */
		public function getRecentPosts(blog_id:int,username:String,password:String,num_posts:int,retFun:Function):void
		{
			var params:Array = new Array(null,blog_id,username,password,num_posts);
			bloggerXmlrpc.invoke("blogger.getRecentPosts",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IBloggerService#getTemplate()
		 */
		public function getTemplate(blog_id:int,username:String,password:String,template:String,retFun:Function):void
		{
			var params:Array = new Array(null,blog_id,username,password,template);
			bloggerXmlrpc.invoke("blogger.getTemplate",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IBloggerService#setTemplate()
		 */
		public function setTemplate(blog_id:int,username:String,password:String,template:String,content:Object,retFun:Function):void
		{
			var params:Array = new Array(null,blog_id,username,password,template,content);
			bloggerXmlrpc.invoke("blogger.setTemplate",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IBloggerService#newPost()
		 */
		public function newPost(blog_id:int,username:String,password:String,content:String,publish:Boolean,retFun:Function):void
		{
			var params:Array = new Array(null,blog_id,username,password,content,publish);
			bloggerXmlrpc.invoke("blogger.newPost",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IBloggerService#editPost()
		 */
		public function editPost(post_id:int,username:String,password:String,content:Object,publish:Boolean,retFun:Function):void
		{
			var params:Array = new Array(null,post_id,username,password,content,publish);
			bloggerXmlrpc.invoke("blogger.editPost",params,retFun);
		}
		/**
		 * @copy cn.airia.as3wplib.service.IBloggerService#deletePost()
		 */
		public function deletePost(post_id:int,username:String,password:String,publish:Boolean,retFun:Function):void
		{
			var params:Array = new Array(null,post_id,username,password,publish);
			bloggerXmlrpc.invoke("blogger.deletePost",params,retFun);
		}
	}
}